package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "customer_", schema = "crm")
public class Customer {
    private int customerId;
    private String customerName;
    private String customerSimplename;
    private Integer customerLifecycle;
    private Integer customerType;
    private Date customerContractdate;
    private Date customerCreatdate;
    private Integer customerFrom;
    private String customerPhone;
    private String customerTel;
    private String customerTip;
    private String customerCompanyname;
    private String customerWork;
    private String customerPeoplenumber;
    private String customerCompanytip;
    private String customerHttp;
    private String customerAddress;
    private String customerImg;
    private Employee employeeByEmpId;
    private Collection<Complain> complainsByCustomerId;
    private Collection<Contact> contactsByCustomerId;
    private Collection<Contract> contractsByCustomerId;
    private Collection<Customercare> customercaresByCustomerId;
    private Collection<Customerservice> customerservicesByCustomerId;
    private Collection<Maintenance> maintenancesByCustomerId;
    private Collection<Opportunity> opportunitiesByCustomerId;
    private Collection<Purchase> purchasesByCustomerId;

    @Id
    @Column(name = "customer_id", nullable = false)
    public int getCustomerId() {
        return customerId;
    }

    public void setCustomerId(int customerId) {
        this.customerId = customerId;
    }

    @Basic
    @Column(name = "customer_name", nullable = true, length = 255)
    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    @Basic
    @Column(name = "customer_simplename", nullable = true, length = 255)
    public String getCustomerSimplename() {
        return customerSimplename;
    }

    public void setCustomerSimplename(String customerSimplename) {
        this.customerSimplename = customerSimplename;
    }

    @Basic
    @Column(name = "customer_lifecycle", nullable = true)
    public Integer getCustomerLifecycle() {
        return customerLifecycle;
    }

    public void setCustomerLifecycle(Integer customerLifecycle) {
        this.customerLifecycle = customerLifecycle;
    }

    @Basic
    @Column(name = "customer_type", nullable = true)
    public Integer getCustomerType() {
        return customerType;
    }

    public void setCustomerType(Integer customerType) {
        this.customerType = customerType;
    }

    @Basic
    @Column(name = "customer_contractdate", nullable = true)
    public Date getCustomerContractdate() {
        return customerContractdate;
    }

    public void setCustomerContractdate(Date customerContractdate) {
        this.customerContractdate = customerContractdate;
    }

    @Basic
    @Column(name = "customer_creatdate", nullable = true)
    public Date getCustomerCreatdate() {
        return customerCreatdate;
    }

    public void setCustomerCreatdate(Date customerCreatdate) {
        this.customerCreatdate = customerCreatdate;
    }

    @Basic
    @Column(name = "customer_from", nullable = true)
    public Integer getCustomerFrom() {
        return customerFrom;
    }

    public void setCustomerFrom(Integer customerFrom) {
        this.customerFrom = customerFrom;
    }

    @Basic
    @Column(name = "customer_phone", nullable = true, length = 255)
    public String getCustomerPhone() {
        return customerPhone;
    }

    public void setCustomerPhone(String customerPhone) {
        this.customerPhone = customerPhone;
    }

    @Basic
    @Column(name = "customer_tel", nullable = true, length = 255)
    public String getCustomerTel() {
        return customerTel;
    }

    public void setCustomerTel(String customerTel) {
        this.customerTel = customerTel;
    }

    @Basic
    @Column(name = "customer_tip", nullable = true, length = 255)
    public String getCustomerTip() {
        return customerTip;
    }

    public void setCustomerTip(String customerTip) {
        this.customerTip = customerTip;
    }

    @Basic
    @Column(name = "customer_companyname", nullable = true, length = 255)
    public String getCustomerCompanyname() {
        return customerCompanyname;
    }

    public void setCustomerCompanyname(String customerCompanyname) {
        this.customerCompanyname = customerCompanyname;
    }

    @Basic
    @Column(name = "customer_work", nullable = true, length = 255)
    public String getCustomerWork() {
        return customerWork;
    }

    public void setCustomerWork(String customerWork) {
        this.customerWork = customerWork;
    }

    @Basic
    @Column(name = "customer_peoplenumber", nullable = true, length = 255)
    public String getCustomerPeoplenumber() {
        return customerPeoplenumber;
    }

    public void setCustomerPeoplenumber(String customerPeoplenumber) {
        this.customerPeoplenumber = customerPeoplenumber;
    }

    @Basic
    @Column(name = "customer_companytip", nullable = true, length = 255)
    public String getCustomerCompanytip() {
        return customerCompanytip;
    }

    public void setCustomerCompanytip(String customerCompanytip) {
        this.customerCompanytip = customerCompanytip;
    }

    @Basic
    @Column(name = "customer_http", nullable = true, length = 255)
    public String getCustomerHttp() {
        return customerHttp;
    }

    public void setCustomerHttp(String customerHttp) {
        this.customerHttp = customerHttp;
    }

    @Basic
    @Column(name = "customer_address", nullable = true, length = 255)
    public String getCustomerAddress() {
        return customerAddress;
    }

    public void setCustomerAddress(String customerAddress) {
        this.customerAddress = customerAddress;
    }

    @Basic
    @Column(name = "customer_img", nullable = true, length = 255)
    public String getCustomerImg() {
        return customerImg;
    }

    public void setCustomerImg(String customerImg) {
        this.customerImg = customerImg;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Customer customer = (Customer) o;
        return customerId == customer.customerId &&
                Objects.equals(customerName, customer.customerName) &&
                Objects.equals(customerSimplename, customer.customerSimplename) &&
                Objects.equals(customerLifecycle, customer.customerLifecycle) &&
                Objects.equals(customerType, customer.customerType) &&
                Objects.equals(customerContractdate, customer.customerContractdate) &&
                Objects.equals(customerCreatdate, customer.customerCreatdate) &&
                Objects.equals(customerFrom, customer.customerFrom) &&
                Objects.equals(customerPhone, customer.customerPhone) &&
                Objects.equals(customerTel, customer.customerTel) &&
                Objects.equals(customerTip, customer.customerTip) &&
                Objects.equals(customerCompanyname, customer.customerCompanyname) &&
                Objects.equals(customerWork, customer.customerWork) &&
                Objects.equals(customerPeoplenumber, customer.customerPeoplenumber) &&
                Objects.equals(customerCompanytip, customer.customerCompanytip) &&
                Objects.equals(customerHttp, customer.customerHttp) &&
                Objects.equals(customerAddress, customer.customerAddress) &&
                Objects.equals(customerImg, customer.customerImg);
    }

    @Override
    public int hashCode() {
        return Objects.hash(customerId, customerName, customerSimplename, customerLifecycle, customerType, customerContractdate, customerCreatdate, customerFrom, customerPhone, customerTel, customerTip, customerCompanyname, customerWork, customerPeoplenumber, customerCompanytip, customerHttp, customerAddress,customerImg);
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Complain> getComplainsByCustomerId() {
        return complainsByCustomerId;
    }

    public void setComplainsByCustomerId(Collection<Complain> complainsByCustomerId) {
        this.complainsByCustomerId = complainsByCustomerId;
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Contact> getContactsByCustomerId() {
        return contactsByCustomerId;
    }

    public void setContactsByCustomerId(Collection<Contact> contactsByCustomerId) {
        this.contactsByCustomerId = contactsByCustomerId;
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Contract> getContractsByCustomerId() {
        return contractsByCustomerId;
    }

    public void setContractsByCustomerId(Collection<Contract> contractsByCustomerId) {
        this.contractsByCustomerId = contractsByCustomerId;
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Customercare> getCustomercaresByCustomerId() {
        return customercaresByCustomerId;
    }

    public void setCustomercaresByCustomerId(Collection<Customercare> customercaresByCustomerId) {
        this.customercaresByCustomerId = customercaresByCustomerId;
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Customerservice> getCustomerservicesByCustomerId() {
        return customerservicesByCustomerId;
    }

    public void setCustomerservicesByCustomerId(Collection<Customerservice> customerservicesByCustomerId) {
        this.customerservicesByCustomerId = customerservicesByCustomerId;
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Maintenance> getMaintenancesByCustomerId() {
        return maintenancesByCustomerId;
    }

    public void setMaintenancesByCustomerId(Collection<Maintenance> maintenancesByCustomerId) {
        this.maintenancesByCustomerId = maintenancesByCustomerId;
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Opportunity> getOpportunitiesByCustomerId() {
        return opportunitiesByCustomerId;
    }

    public void setOpportunitiesByCustomerId(Collection<Opportunity> opportunitiesByCustomerId) {
        this.opportunitiesByCustomerId = opportunitiesByCustomerId;
    }

    @OneToMany(mappedBy = "customerByCustomerId")
    public Collection<Purchase> getPurchasesByCustomerId() {
        return purchasesByCustomerId;
    }

    public void setPurchasesByCustomerId(Collection<Purchase> purchasesByCustomerId) {
        this.purchasesByCustomerId = purchasesByCustomerId;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "customerId=" + customerId +
                ", customerName='" + customerName + '\'' +
                ", customerSimplename='" + customerSimplename + '\'' +
                ", customerLifecycle=" + customerLifecycle +
                ", customerType=" + customerType +
                ", customerContractdate=" + customerContractdate +
                ", customerCreatdate=" + customerCreatdate +
                ", customerFrom=" + customerFrom +
                ", customerPhone='" + customerPhone + '\'' +
                ", customerTel='" + customerTel + '\'' +
                ", customerTip='" + customerTip + '\'' +
                ", customerCompanyname='" + customerCompanyname + '\'' +
                ", customerWork='" + customerWork + '\'' +
                ", customerPeoplenumber='" + customerPeoplenumber + '\'' +
                ", customerCompanytip='" + customerCompanytip + '\'' +
                ", customerHttp='" + customerHttp + '\'' +
                ", customerAddress='" + customerAddress + '\'' +
                ", employeeByEmpId=" + employeeByEmpId +
                ", complainsByCustomerId=" + complainsByCustomerId +
                ", contactsByCustomerId=" + contactsByCustomerId +
                ", contractsByCustomerId=" + contractsByCustomerId +
                ", customercaresByCustomerId=" + customercaresByCustomerId +
                ", customerservicesByCustomerId=" + customerservicesByCustomerId +
                ", maintenancesByCustomerId=" + maintenancesByCustomerId +
                ", opportunitiesByCustomerId=" + opportunitiesByCustomerId +
                ", purchasesByCustomerId=" + purchasesByCustomerId +
                ", customerImg=" + customerImg +
                '}';
    }
}
